feat(igc): enable tx checksum offload#694
Merged
Merged
Conversation
- Add ActiveChecksumContext enum to Tx to track and reuse context descriptors - Add igc_tx_ctx_setup() to program the Advanced TX Context Descriptor for IPv4, TCP/IPv4, and UDP/IPv4 checksum offload - Update igc_send() to prepend a context descriptor when offload context changes - Advertise CSUM_IPv4, CSUM_TCPv4, and CSUM_UDPv4 capabilities - Enable TCP checksum offload in if_net and update the capability comment Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds IPv4/TCPv4/UDPv4 TX checksum offload support for the Intel IGC (I225/I226) driver by introducing advanced TX context descriptors and advertising the corresponding network capabilities so the stack can request hardware checksum insertion.
Changes:
- Add tracking for the “active” TX checksum context and emit an Advanced TX Context Descriptor when the offload context changes.
- Advertise
CSUM_IPv4,CSUM_TCPv4, andCSUM_UDPv4capabilities in the IGC driver and enable TCP checksum offload in the network interface capabilities mapping. - Extend IGC descriptor definitions/structures to support Advanced Context Descriptors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| awkernel_lib/src/net/if_net.rs | Enables TCP checksum offload reporting to smoltcp when the device advertises CSUM_TCPv4. |
| awkernel_drivers/src/pcie/intel/igc/igc_defines.rs | Adds constants needed to build Advanced TX Context Descriptors for checksum offload. |
| awkernel_drivers/src/pcie/intel/igc/igc_base.rs | Extends the advanced TX descriptor union to include the context descriptor view. |
| awkernel_drivers/src/pcie/intel/igc.rs | Implements context descriptor setup, context reuse tracking, capability advertisement, and send-path changes to prepend context descriptors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Validated on real I225 hardware (UDP echo + TCP both work, valid on-wire checksums confirmed via tcpdump on the peer). - IP header length in the advanced context descriptor was programmed in 32-bit words instead of bytes (`header_len()` returns IHL). With the wrong length the NIC mis-placed the checksums and IP packets never egressed correctly; shift IHL left by 2 to get bytes (matches the igb driver). - Seed the IPv4 pseudo-header checksum into the L4 checksum field before DMA. smoltcp leaves it zero when TX checksum is offloaded, so without the seed the NIC computed segment-only checksums and every TCP/UDP checksum was wrong on the wire. Add `igc_pseudo_cksum()` and write it at the L4 csum offset. - Restore `active_checksum_context` when `igc_send()` bails out due to insufficient descriptors, so the software context cannot desync from what the hardware actually saw (addresses the review's state-desync concern). - Reclaim context descriptors in `igc_txeof()`: they carry no DD writeback, so the per-descriptor DD scan would stall at the first one and eventually wedge TX once the ring filled. Treat a non-DD descriptor whose successor is done as a consumed context descriptor. - Derive `Copy, Clone` for `ActiveChecksumContext` to support the snapshot. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Factor the L4 checksum seed `(usize, u16)` into a `L4CksumSeed` type alias so `igc_tx_ctx_setup`'s return type is no longer flagged by clippy::type_complexity. No behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
atsushi421
reviewed
Jun 10, 2026
Validated on real I225 hardware (UDP echo + TCP, all egress checksums valid).
- igc_txeof: guard the context-descriptor look-ahead against the producer
index so reclaim can never advance `next_to_clean` at/past `next_avail_desc`
and corrupt `igc_desc_unused()` accounting.
- igc_send: reserve room for the worst case (ctx + data) with an up-front
`igc_desc_unused() < 2` check (OpenBSD igc style), removing the fragile
snapshot/restore of `active_checksum_context` on the bail-out path.
- igc_tx_ctx_setup:
- fast-path early return when `csum_flags` is empty, skipping header parsing
on packets that need no offload (e.g. ARP).
- drop (InvalidPacket) when `extract_headers` fails on an offload-requested
frame instead of posting an unchecksummed packet (mirrors igb/ixgbe).
- drop IP fragments: the L4 header is not at the expected offset and hardware
L4 offload cannot complete a fragmented checksum.
- account for an inline 802.1Q VLAN tag (18-byte L2 header) when computing
MACLEN and the pseudo-header seed offset.
- if_net::tx_packet_header_flags: gate TCP/UDP_CSUM_OUT on IPv4 so a non-IPv4
(e.g. IPv6) TCP/UDP packet is not left with an unfilled checksum.
- Add IgcDriverErr::InvalidPacket.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
atsushi421
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Related links
How was this PR tested?
Notes for reviewers